﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TaoPortal.BusinessLogic.Repository;

namespace TaoPortal.Controllers
{
    public class DeownloadFileController : Controller
    {
        //
        // GET: /DeownloadFile/

        public void Index(string id)
        {
            var frp = new FileRepository();
            var f = frp.GetFile(id);
            Response.AddHeader("Content-Disposition", "attachment;filename=" + f.FName + f.FExtName);
            Response.AddHeader("Content-Length", f.FLength.ToString());
            Response.ContentType = f.FType;
            Response.ContentEncoding = System.Text.Encoding.Default;
            Response.BinaryWrite(f.FData);
            Response.Flush();
            Response.End();
        }

    }
}
